package com.lyf.Array;

import java.util.Scanner;

public class TwoArray {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入一个数：");
        int n=sc.nextInt();
        start(n);
        //打乱


    }
    public static void start(int n){
        int[][] arr=new int[n][n];
        int temp=1;
        for(int i=0;i<n;i++){
            for(int j = 0; j <n; j++) {
                arr[i][j]=temp++;

            }

        }
        printstart(arr);
        rprint(arr);
        System.out.println("-------------------------------------");
        printstart(arr);
    }

    public static void printstart(int[][] arr){

        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr[i].length; j++) {
                System.out.print(arr[i][j]+"\t\t");
            }
            System.out.println();
        }


    }

    public static void rprint(int[][] arr){
        int temp=0;
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr[i].length; j++) {
                int n=(int) (Math.random()*arr.length);
                int m=(int) (Math.random()*arr.length);
                temp=arr[i][j];
                arr[n][m]=arr[i][j];
                arr[i][j]=temp;
            }

        }
    }
}
